library(ggplot2)
#library(grid)
library(gridExtra)
library(cowplot)

#rm(list=ls())
#application<-1;

##% whether we want to produce figures, and/or estimates, and/or bias corrections

Psihat.saved<-list()
##%simulations draws for p(z,theta) specifications
#pathname<-"/Users/virasemenora/Dropbox (MIT)/Isaiah Andrews Replication"
zdrawcount<-5*1000;
thetadrawcount<-5*1000;
zdrawsd<-5;
thetadrawsd<-4;
vcutoff<-1.96;
seed<-888
dofis1<-NULL
##%variable identificationapproach will be set later
##% 1: replications
##% 2: variation in variance

setup<-function(data, sym) {
  filepath<-"NULL";
  my.data<-data;
  X=my.data[,1];
  number=length(X);
  cluster_ID=my.data[,3];
  
  includeinfigure<-as.logical(rep(1,number));
  includeinestimation<-as.logical(rep(1,number))
  
  sigma<-my.data[,2];
  identificationapproach=2;
  name="data";
  #%Estimate baseline model, rather than running spec test
  spec_test=0;   
  #%Set number of normal draws for monte-carlo integration
  #ndraws=10^4;
  #%Set cutoffs to use in step function: should be given in increasing order;
  cutoffs=c(-1.96,0,1.96);
  #%Use a step function symmetric around zero
  symmetric=0;

  if(sym){
    symmetric_p=1;
    Psihat0=c(0,1,1);
    application<<-10;
  }else{
    symmetric_p=0;
    Psihat0=c(0,1.1,1,1,1);
    application<<-7;
  }
  
  args1<<-list(filepath=filepath,
               dofis1=dofis1,
               Z=NULL,
               sigmaZ2=NULL, #sigmaZ2,
               X=X,
               number=number,
               sigma=sigma,
               cluster_ID=cluster_ID,
               Psihat0=Psihat0,
               name = name,
               symmetric= symmetric,
               symmetric_p=symmetric_p,
               cutoffs = cutoffs,
               spec_test = spec_test,
               identificationapproach = identificationapproach,
               includeinestimation=includeinestimation,
               my.data=my.data)
  return(args1)
}



